﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Rsa
{
    /// <summary>
    /// Interaction logic for JanelaTwitter.xaml
    /// </summary>
    public partial class JanelaTwitter : UserControl
    {
        GestorConfigXML Gxml = null;
        private List<Lista> ListaTwitter = new List<Lista>();
        private LancarThreads _lancar = null;
        private GestorTwitter t;

        public JanelaTwitter(GestorConfigXML gx)
        {
            InitializeComponent();
            Gxml = gx;
        }

        public void atualizarTwitter(List<Lista> myLista)
        {
            //if (myLista != null)
            //{
            //    ListaTwitter = myLista;
            //    listaBox.Items.Clear();
            //    foreach (Lista l in myLista)
            //        listaBox.Items.Add(l);
            //}
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            t = new GestorTwitter(Gxml);
            t.Dados(1);
        }


        public LancarThreads Lancar
        {
            get { return _lancar; }
            set { 
                _lancar = value;
                Lancar.twitterEvento += new LancarThreads.TwitterHandler(atualizarTwitter);
            }
        }


        private void button2_Click(object sender, RoutedEventArgs e)
        {
            t = new GestorTwitter(Gxml);
            if ( !string.IsNullOrEmpty(textBoxPost.Text.ToString()))
            {
                Console.WriteLine("A Linha Nao esta vazia");
                t.Post(textBoxPost.Text);
            }
            else
                Console.WriteLine("A linha esta vazia");

            textBoxPost.Text = "";
        }

        private void listaBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
    }
}
